package project.dao.impl;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import project.dao.GradeDao;
import project.entity.Grade;
import project.utils.DruidUtil;

import java.sql.SQLException;
import java.util.List;

/*
杨威
2021/9/16
11:40
*/
public class GradeDaoImpl implements GradeDao {
    QueryRunner queryRunner=new QueryRunner();
    @Override
    public List<Grade> selectAll() {
        try {
            String sql="select * from grade";
            return queryRunner.query(DruidUtil.getConnection(),sql,new BeanListHandler<>(Grade.class));
        } catch (SQLException e) {
            throw new RuntimeException(e.getMessage()+"查询所有班级出现异常");
        }
    }
}
